package com.dog.basics.admin.controller.common;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.common.GuidePageAddDto;
import com.dog.basics.bean.dto.admin.common.GuidePageEditDto;
import com.dog.basics.bean.dto.admin.common.GuidePageFromDto;
import com.dog.basics.bean.vo.admin.common.GuidePageVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.constant.SwaggerConstants;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.common.IDogGuidePageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 引导页和启动页 前端控制器
 * </p>
 *
 * @author wph
 * @since 2020-05-27
 */
@RestController
@RequestMapping("/admin/guide/page")
@Api(value = SwaggerConstants.COMMON+"引导页和启动页", tags = SwaggerConstants.COMMON+"引导页和启动页")
@AllArgsConstructor
public class DogGuidePageController {
    private final IDogGuidePageService dogGuidePageService;

    /**
     * @Description: 引导页和启动页列表
     * @Param: status
     * @return: IPage<GuidePageVo>
     * @Author: wph
     * @Date:
     */
    @ApiOperation(value = "引导页和启动页列表", notes = "pc:dogGuidePage:page")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('pc:dogGuidePage:page')")
    public R<IPage<GuidePageVo>> page(PageParam page, GuidePageFromDto obj) {
        IPage<GuidePageVo> list = dogGuidePageService.getPageList(page, obj);
        return R.ok(list);
    }

    /**
     * @Description: 增加引导页和启动页
     * @Param: PlateAddDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("增加引导页和启动页")
    @ApiOperation(value = "增加引导页和启动页", notes = "pc:dogGuidePage:save")
    @PostMapping("/save")
    @PreAuthorize("@pms.hasPermission('pc:dogGuidePage:save')")
    public R<Boolean> save(@Valid @RequestBody GuidePageAddDto obj) {
        return R.ok(dogGuidePageService.saveObj(obj));
    }

    /**
     * @Description: 删除引导页和启动页
     * @Param: ids
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("删除引导页和启动页")
    @ApiOperation(value = "删除引导页和启动页", notes = "pc:dogGuidePage:delete")
    @ApiImplicitParam(value = "引导页和启动页Id", name = "id", dataType = "List<Long>", required = true)
    @DeleteMapping("/delete/{id}")
    @PreAuthorize("@pms.hasPermission('pc:dogGuidePage:delete')")
    public R<Boolean> delete(@RequestBody List<Long> id) {
        return R.ok(dogGuidePageService.deleteObj(id));
    }

    /**
     * @Description: 修改引导页和启动页
     * @Param: PlateEditDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("修改引导页和启动页")
    @ApiOperation(value = "修改引导页和启动页", notes = "pc:dogGuidePage:edit")
    @PutMapping("/edit")
    @PreAuthorize("@pms.hasPermission('pc:dogGuidePage:edit')")
    public R<Boolean> edit(@Valid @RequestBody GuidePageEditDto obj) {
        return R.ok(dogGuidePageService.editObj(obj));
    }
}
